package com.sen.mapper;

import com.sen.dto.Part;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PartMapper {

    /**
     * 查询某个视频的选集
     *
     * @param bv 视频号
     * @return
     */
    @Select("""
            SELECT  `pid`, `title`, `url`, `duration` FROM part WHERE  `bv`=#{bv}
            """)
    List<Part> findByBv(String bv);


    /**
     * 插入part表数据
     *
     * @param part part对象
     * @param bv   bv号
     */
    @Insert("""
            INSERT INTO part (`pid`, `title`, `url`, `duration`, `bv`) 
            VALUES (#{p.pid}, #{p.title}, #{p.url}, #{p.duration}, #{bv})
            """)
    void insert(@Param("p") Part part, @Param("bv") String bv);

}
